<%@ page import="edu.njfu.sas.dao.StudentDao" %>
<%@ page import="edu.njfu.sas.dao.impl.StudentDaoImpl" %>
<%@ page import="edu.njfu.sas.model.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: guzhe
  Date: 2020/12/10
  Time: 8:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生列表展示</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<hr>
<h1 align="center">软件工程18级学生信息表</h1>
<hr>
<form  action="liststudents.jsp" method="post">
    请输入姓名：<input  type="text" name="userName" id="userName"/>
    <input type="submit" name="submit" id="submit" value="确定"/>
</form>
<hr>
<table>
    <tr>
        <td>学号</td>
        <td>姓名</td>
        <td>班级</td>
        <td>性别</td>
        <td>系部</td>
        <td>电话</td>
        <td>宿舍号</td>
        <td>照片</td>
        <td>操作</td>
    </tr>
<%
    String submit = request.getParameter("submit");
    //String userName=request.getParameter("userName");
    StudentDao sdao=new StudentDaoImpl();
    List<Student> students=null;
    if(submit!=null && submit.equals("确定")){
       //查询操作
        //获取字符串
        String  name = request.getParameter("userName");
        //调用查询结果
      students=sdao.getStudentByName(name);
    }else{
        students=sdao.getAllStudent();
    }
    for(Student s:students){
%>
<%--用于学生列表展示--%>
    <tr>
        <td><%=s.getStuNo()%></td>
        <td><%=s.getStuName()%></td>
        <td><%=s.getClasses()%></td>
        <td><%=s.getGender()%></td>
        <td><%=s.getDepartment()%></td>
        <td><%=s.getTel()%></td>
        <td><%=s.getDormNo()%></td>
        <td>
           <img src="<%=s.getPhotoPath()%>" style="width: 50px" height="50px"/>
        </td>
        <td>
            <a href="updatestudent.jsp?stuno=<%=s.getStuNo()%>">更新</a>
        </td>
    </tr>
    <%
        }
     %>
</table>
</body>
</html>
